<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var operateCode = document.getElementById("operateCode");
		var operateName = document.getElementById("operateName");
		
		if(operateCode.value == ""){
			alert("<fmt:message key='func.lable.operateCode'/><fmt:message key='common.message.empty'/>");
			return false;
		}
		
		if(operateName.value == ""){
			alert("<fmt:message key='func.lable.operateName'/><fmt:message key='common.message.empty'/>");
			return false;
		}
		return true;
	}

	function back(){
		window.location.href = "./functionTree.do";
		window.location.target = "main";
	}
	
	function save(){
		if(checkForm()){
			document.addOperateForm.action = "./operate.do?action=addOperate";
			document.addOperateForm.target = "main";
			document.addOperateForm.submit();
		}
	}
	
	function deleteOperate(id,functionId){
		window.location.href = "./operate.do?action=deleteOperateByAdd&id="+id+"&functionId="+functionId;
		window.location.target = "main";
	}
	
	function initPage(result,repeat,del){
		if(result == 1){
			alert("<fmt:message key='common.message.addSuccess'/>");
		}
		if(repeat == 1){
			alert("<fmt:message key='common.message.addFail'/><fmt:message key='func.lable.operateCode'/><fmt:message key='common.message.exist'/>");
		}
		if(del == 1){
			alert("<fmt:message key='common.message.deleteSuccess'/>");
		}
	}
	
	
-->
</script>
</head>
<body onload="initPage('${result}','${repeat}','${delete}')">
<form name="addOperateForm" action="" method="post">
	<table class="table_frame" cellpadding="0" cellspacing="0">
		<tr>
			<td>
				<table class="table_title" cellpadding="0" cellspacing="0">
					<tr>
						<td class="title_lab" colspan="3">
							&nbsp;&nbsp;&nbsp;&nbsp;<fmt:message key='func.title.addOperate'/>
						</td>
					</tr>
					<tr><td height="15"></td></tr>
					<tr>
						<td valign="bottom">&nbsp;
							<a href="javascript:save();" title="<fmt:message key='common.button.save'/>" hidefocus="true"><fmt:message key='common.button.save'/></a>
						</td>
						<td valign="bottom" align="right">
							<a href="javascript:back();" title="<fmt:message key='common.button.back'/>" hidefocus="true"><fmt:message key='common.button.back'/></a>&nbsp;&nbsp;&nbsp;&nbsp;
						</td>
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td height="5"></td>
		</tr>
		<tr>
			<td>
				<table class="table_input1" cellpadding="0" cellspacing="0">
					<tr><td class="title3" colspan="5"></td></tr>
					<tr>
						<td width="1%"></td>
						<td class="" width="15%"><fmt:message key='func.lable.operateCode'/><fmt:message key='common.sign'/><input id="functionId" name="functionId" type="hidden" value="${functionId}"/></td>
						<td class=""><input id="operateCode" name="operateCode" class="input_long" type="text" value="${operate.operateCode}"/></td>
					</tr>
					<tr>
						<td width="1%"></td>
						<td class="" width="15%"><fmt:message key='func.lable.operateName'/><fmt:message key='common.sign'/></td>
						<td class=""><input id="operateName" name="operateName" class="input_long" type="text" value="${operate.operateName}"/></td>
					</tr>
					<tr>
						<td width="1%"></td>
						<td class="" width="15%"><fmt:message key='func.lable.operateNameEn'/><fmt:message key='common.sign'/></td>
						<td class=""><input id="operateNameEn" name="operateNameEn" class="input_long" type="text" value="${operate.operateNameEn}"/></td>
					</tr>
					<tr>
						<td width="1%"></td>
						<td class="title3" width=""><fmt:message key='common.lable.isActivity'/><fmt:message key='common.sign'/></td>
						<td class="title3" width="">
							<input name="isActivity" type="radio" <c:if test='${operate.isActivity == 1 || operate.isActivity == null}'>checked</c:if> value="1"/><fmt:message key='common.lable.is'/>&nbsp;&nbsp;
							<input name="isActivity" type="radio" <c:if test='${operate.isActivity == 0}'>checked</c:if> value="0"/><fmt:message key='common.lable.no'/>
						</td>
					</tr>
					<tr><td class="title3" colspan="5"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td valign="top">
				<table class="table_style" style="text-align: center;">
					<tr>
						<td class="title4"><fmt:message key='func.lable.operateCode'/></td>
						<td class="title4"><fmt:message key='func.lable.operateName'/></td>
						<td class="title4" width="15%"><fmt:message key='common.lable.isActivity'/></td>
						<td class="title4" width="15%"><fmt:message key='common.lable.operate'/></td>
					</tr>
					<c:forEach var="operate" items="${operates}">
					<tr>
						<td>${operate.operateCode}</td>
						<td>${operate.operateName}</td>
						<td>
							<c:choose>
								<c:when test="${operate.isActivity == 1}"><fmt:message key='common.lable.is'/></c:when>
								<c:otherwise><fmt:message key='common.lable.no'/></c:otherwise>
							</c:choose>
						</td>
						<td>
							<img class="btn_img" src="./images/a_del.gif" onclick="deleteOperate(${operate.id},${operate.functionId})" title="<fmt:message key='common.button.delete'/>">&nbsp;&nbsp;
						</td>
					</tr>
					</c:forEach>
				</table>
			</td>
		</tr>
	</table>
</form>
</body>
</html>